Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate expect and @jest/expect type tests to TSTyche #14910

Merged
merged 4 commits into from
Mar 8, 2024
Merged

chore: migrate expect and @jest/expect type tests to TSTyche #14910

merged 4 commits into from
Mar 8, 2024

Conversation

mrazauskas
Copy link
Contributor

Summary

This PR migrates expect and @jest/expect type tests to TSTyche. The diff is noisy, but the tests look much better.

Test plan

Type test must pass in CI.

Copy link

netlify bot commented Feb 20, 2024

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 75b60cf
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/65e55b566c6b75000853fd47
😎 Deploy Preview https://deploy-preview-14910--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +20 to +22
expect(jestExpect(null)).type.toHaveProperty('toMatchSnapshot');

expect(_expect(null)).type.not.toHaveProperty('toMatchSnapshot');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TSTyche can check if property exists. That’s way better than just expectError.

Comment on lines +31 to +34
test('is superset of `Expect`', () => {
expect<typeof jestExpect>().type.toMatch<typeof _expect>();

expect<typeof _expect>().type.not.toMatch<typeof jestExpect>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun to play with .toMatch(). That’s another novelty and it does the right job here.

});

test('does not define the `.toMatchSnapshot()` matcher', () => {
expect(_expect(null)).type.not.toHaveProperty('toMatchSnapshot');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jestExpect would not look right here, or? This is expectExpect, but expect(expectExpect is somewhat too much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha

@mrazauskas
Copy link
Contributor Author

@SimenB Did I address all your comments? Or did I miss something? No rush, if you are busy. This can wait. Just checking if some more changes are expected or not.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great stuff, thanks!

@SimenB SimenB merged commit 3f2161f into jestjs:main Mar 8, 2024
72 of 73 checks passed
@mrazauskas mrazauskas deleted the migrate-expect-type-tests branch March 8, 2024 12:00
Copy link

github-actions bot commented Apr 9, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants